<template>
	<view class="uni_box home">
		<navbar title='套餐服务'>
		</navbar>
		<view class="content">
			<view class="vipone">
				<image class="viphead" src="/static/img/viphead.png"></image>
				<view class="viponeitem">
				 <image class="img_wg" src="/static/img/img_wg.png"></image>
				  <view class="shione">
					<image class="icon_hy" src="/static/img/icon_hy.png"></image>
					<text class="hname">律小狮会员</text>
				  </view>	
				  <text class="daoqi">会员到期时间：{{user.vip_date}}</text>
				  <view class="kai">
					开通即享会员期间不限次AI法务咨询服务/合同模板下载/不定期法律讲堂等多项权益
				  </view>
				</view>
			</view>
			<view class="viptwo">
				<text class="vname">会员套餐</text>
				<view class="vlist">
					<scroll-view scroll-x class="vitem">
						<!-- <view class="items active">
							<image class="vipbg" src="/static/img/vipbg.png"></image>
							<view class="itemview">
								
								<image class="icon_vip" src="/static/img/icon_vip.png"></image>
								<text class="huiname">月会员</text>
								<text class="jia">￥<text class="jianum">99</text></text>
								<text class="yuan">￥199</text>
							</view>
						</view> -->
						<view class="items" :class="vipindex.id == item.id?'active':''" v-for="(item,index) in package_user" :key="index" @click="vipClick(item)">
							<image class="vipbg" src="/static/img/vipbg.png"></image>
							<view class="itemview">
								<image class="icon_vip" :src="item.logo"></image>
								<text class="huiname">{{item.name}}</text>
								<text class="jia">￥<text class="jianum">{{ item.price }}</text></text>
								<text class="yuan">￥{{ item.original_price }}</text>
							</view>
						</view>
					</scroll-view>
				</view>
			</view>

			<view class="vipthree">
				<view class="vhead">
					<image class="img_zs" src="/static/img/img_zs.png"></image>
					<text class="quanyi">会员权益</text>
				</view>
			</view>

			<view class="hlist">
				<view class="hitem" v-for="(item,index) in vipindex.equity" :key="index" @click="navClick(item)">
					<image class="hicon" :src="item.equity.thumbnail"></image>
					<text>{{item.equity.name}}</text>
				</view>
			</view>
			<view class="botview">
				<view class="botbtn" @click="getxiadan">立即支付</view>
				<!-- <view class="botbtn">提交信息</view> -->
			</view>
			
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				hList:[
					{id:1,name:'Ai法务',img:'/static/img/icon_ai.png'},
					{id:2,name:'合同模版',img:'/static/img/icon_ht.png'},
					{id:3,name:'法律讲堂',img:'/static/img/icon_jt.png'},
					{id:4,name:'更多权益',img:'/static/img/icon_qy.png'}
				],
				user:{

				},
				package_user:[],
				vipindex:{},
				equitydata:[]
			}
		},
		onLoad() {
			this.getuserinfo()
			this.getviplist()
			// this.getequity();
		},
		onShow() {
		},
		methods: {
			async getuserinfo(){
				let res = await this.$u.api.userinfo({
				});
				this.user = res.user
			},
			async getequity(){
				let res = await this.$u.api.equity({
				});
				this.equitydata = res
				
			},
			async getviplist(){
				let res = await this.$u.api.uservip({
				});
				this.package_user = res.package_user
				this.vipindex = this.package_user[0]
				// this.equitydata = 
			},
			vipClick(item){
				this.vipindex = item
			},
			async getxiadan(){
				let res = await this.$u.api.orderplace({
					type:'1',
					id:this.vipindex.id
				});
				this.$u.toast("操作成功");
			}

		}
	}
</script>

<style lang="scss" scoped>
	page{
		background-color: #fff;
	}
	.content{
		background-color: #fff;
		padding-bottom: 150rpx;
		.vipone{
			margin: 30rpx;
			height: 300rpx;
			position: relative;
			.viphead{
				position: absolute;
				width: 100%;
				height: 100%;

			}
			.viponeitem{
				position: relative;
				padding: 50rpx 40rpx 24rpx;
				display: flex;
				height: 100%;
				flex-direction: column;
				margin-top: 60rpx;
				.img_wg{
					position: absolute;
					width: 240rpx;
					height: 180rpx;
					right: 0;
					top: -60rpx;
				}
				.shione{
					display: flex;
					flex-direction: row;
					align-items: center;
					.icon_hy{
						margin-right: 11rpx;
						width: 40rpx;
						height: 40rpx;

					}
					.hname{
						font-family: PingFang SC;
						font-weight: 800;
						font-size: 40rpx;
						color: #52360F;
					}
				}
				.daoqi{
					font-family: PingFang SC;
					font-weight: 500;
					font-size: 26rpx;
					color: #8D6B3C;
					display: block;
					margin-top: 20rpx;
				}
				.kai{
					margin-top: auto;
					padding: 15rpx 20rpx;
					background: rgba(255,255,255,0.3);
					border-radius: 10rpx;
					font-family: PingFang SC;
					font-weight: 500;
					font-size: 20rpx;
					color: #8D6B3C;
				}
			}
		}
		.viptwo{
			padding: 20rpx 30rpx;
			.vname{
				font-family: PingFang SC;
				font-weight: bold;
				font-size: 36rpx;
				color: #52360F;
				display: block;
				margin-bottom: 25rpx;
			}
			.vlist{
				.vitem{
					white-space: nowrap;
					.items{
						width: 204rpx;
						height: 285rpx;
						background: #F5F5F5;
						border-radius: 20rpx;
						margin-right: 30rpx;
						display: inline-block;
						position: relative;
						.vipbg{
							position: relative;
							width: 100%;
							height: 100%;
							position: absolute;
							display: none;
						}
						.itemview{
							width: 100%;
							height: 100%;
							position: relative;
							display: flex;
							align-items: center;
							flex-direction: column;
							.icon_vip{
								width: 80rpx;
								height: 80rpx;
								margin-bottom: 6rpx;
								margin-top: 8rpx;
								margin-bottom: 8rpx;
							}
							.huiname{
								font-family: PingFang SC;
								font-weight: bold;
								font-size: 24rpx;
								color: #333333;
							}
							.jia{
								font-family: PingFang SC;
								font-weight: bold;
								font-size: 24rpx;
								color: #111111;
								display: block;
								margin-top: 30rpx;
							}
							.jianum{
								font-size: 50rpx;
							}
							.yuan{
								font-family: PingFang SC;
								font-weight: bold;
								font-size: 20rpx;
								color: #999999;
								text-decoration-line: line-through;
							}
						}
					}
					.active{
						.itemview{
							.huiname{
								color: #B46D0C;
							}
							.jia{
								color: #B46D0C;
							}
						}
						.vipbg{
							display: inline-block;
						}
					}
					
				}
			}
		}
		.vipthree{
			margin: 80rpx 30rpx 30rpx;
			.vhead{
				width: 379rpx;
				margin: 0 auto;
				position: relative;
				display: flex;
				align-items: center;
				justify-content: center;
				.img_zs{
					width: 100%;
					height: 4rpx;
					position: absolute;

				}
				.quanyi{
					font-family: PingFang SC;
					font-weight: bold;
					font-size: 32rpx;
					color: #7F664A;
				}
			}
		}

		.hlist{
				display: flex;
				flex-direction: row;
				flex-wrap: wrap;
				margin: 50rpx 0rpx;
				.hitem{
					display: flex;
					flex-direction: column;
					align-items: center;
					justify-content: center;
					width: 25%;
					margin-bottom: 44rpx;
					.hicon{
						width: 100rpx;
						height: 100rpx;
						margin-bottom: 12rpx;
						border-radius: 50%;
					}
					text{
						font-family: PingFang SC;
						font-weight: 500;
						font-size: 26rpx;
						color: #333333;
					}
				}
			}
		.zhifu{
			height: 98rpx;
			background: linear-gradient(90deg, #F4DAB5, #E7B775);
			border-radius: 20rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			font-family: PingFang SC;
			font-weight: 500;
			font-size: 32rpx;
			color: #52360F;
		}
		.botview{
			position: fixed;
			width: 100%;
			height: 120rpx;
			background-color: #fff;
			bottom: 0;
			display: flex;
			align-items: center;
			justify-content: center;
			.botbtn{
				height: 88rpx;
				background: linear-gradient(90deg, #F4DAB5, #E7B775);
				border-radius: 20rpx;
				display: flex;
				align-items: center;
				justify-content: center;
				font-family: PingFang SC;
				font-weight: 500;
				font-size: 32rpx;
				color: #52360F;
				width: 94%;
			}
		}
	}
</style>
